﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace testTennis
{
    [TestClass]
    public class TestGame
    {
        Player player1, player2;
        String server, receiver;
        String serverPoints, receiverPoints;

        public TestGame()
        {
            server = "";
            receiver = "";
            serverPoints = "0";
            receiverPoints = "0";

            player1 = new Player();
            player2 = new Player();
        }

        [TestMethod]
        public void Test_Khoi_Tao_Game()
        {
            player1.setPlayerName("P1");
            player2.setPlayerName("P2");

            server = player1.getPlayerName();
            receiver = player2.getPlayerName();

            Assert.AreNotEqual(server, receiver);
        }

        [TestMethod]
        public void Test_Khoi_Tao_Game_Diem_Bang_Khong()
        {
            Assert.AreEqual(serverPoints, "0");
            Assert.AreEqual(receiverPoints, "0");
        }

        [TestMethod]
        public void Test_0_15_Server_Lose()
        {
            player1.setCurrentPoint("0");


            Assert.AreEqual(player1.getCurrentPoint(), "0");
        }

        [TestMethod]
        public void Test_0_15_Reciever_Win()
        {
            player2.setCurrentPoint("0");
            player2.increasePoints();

            Assert.AreEqual(player2.getCurrentPoint(), "15");
        }

        [TestMethod]
        public void Test_15_0_Server_Win()
        {
            player1.setCurrentPoint("0");
            player1.increasePoints();

            Assert.AreEqual(player1.getCurrentPoint(), "15");
        }

        [TestMethod]
        public void Test_15_0_Receiver_Lose()
        {
            player2.setCurrentPoint("0");


            Assert.AreEqual(player2.getCurrentPoint(), "0");
        }

        [TestMethod]
        public void Test_15_15_Server_equal_Receiver()
        {
            player1.setCurrentPoint("0");
            player1.increasePoints();

            Assert.AreEqual(player1.getCurrentPoint(), "15");
        }
        
        [TestMethod]
        public void Test_15_15_Server_equall_Receiver()
        {
            player2.setCurrentPoint("15");

            Assert.AreEqual(player2.getCurrentPoint(), "15");
        }
        
        [TestMethod]
        public void Test_0_30_Server_Lose()
        {
            player1.setCurrentPoint("0");


            Assert.AreEqual(player1.getCurrentPoint(), "0");
        }
        
        [TestMethod]
        public void Test_0_30_Receiver_Win()
        {
            player2.setCurrentPoint("15");
            player2.increasePoints();

            Assert.AreEqual(player2.getCurrentPoint(), "30");
        }
        
        [TestMethod]
        public void Test_15_15_Receiver_equal_Server()
        {
            player1.setCurrentPoint("15");

            Assert.AreEqual(player1.getCurrentPoint(), "15");
        }
        
        [TestMethod]
        public void Test_15_15_Receiver_equall_Server()
        {
            player2.setCurrentPoint("0");
            player2.increasePoints();

            Assert.AreEqual(player2.getCurrentPoint(), "15");
        }
        
        [TestMethod]
        public void Test_30_0_Server_Win()
        {
            player1.setCurrentPoint("15");
            player1.increasePoints();

            Assert.AreEqual(player1.getCurrentPoint(), "30");
        }
        
        [TestMethod]
        public void Test_30_0_Receiver_Lose()
        {
            player2.setCurrentPoint("0");

            Assert.AreEqual(player2.getCurrentPoint(), "0");
        }
        
        [TestMethod]
        public void Test_15_30_Server_Lose()
        {
            player1.setCurrentPoint("15");

            Assert.AreEqual(player1.getCurrentPoint(), "15");
        }
        
        [TestMethod]
        public void Test_15_30_Receiver_Win()
        {
            player2.setCurrentPoint("15");
            player2.increasePoints();

            Assert.AreEqual(player2.getCurrentPoint(), "30");
        }
        
        [TestMethod]
        public void Test_30_15_Server_Win()
        {
            player1.setCurrentPoint("15");
            player1.increasePoints();

            Assert.AreEqual(player1.getCurrentPoint(), "30");
        }
        
        [TestMethod]
        public void Test_30_15_Receiver_Lose()
        {
            player2.setCurrentPoint("15");

            Assert.AreEqual(player2.getCurrentPoint(), "15");
        }
        
        [TestMethod]
        public void Test_0_40_Server_Lose()
        {
            player1.setCurrentPoint("0");

            Assert.AreEqual(player1.getCurrentPoint(), "0");
        }
        
        [TestMethod]
        public void Test_0_40_Receiver_Win()
        {
            player2.setCurrentPoint("30");
            player2.increasePoints();

            Assert.AreEqual(player2.getCurrentPoint(), "40");
        }
        
        [TestMethod]
        public void Test_15_30_Serverr_Lose()
        {
            player1.setCurrentPoint("0");
            player1.increasePoints();

            Assert.AreEqual(player1.getCurrentPoint(), "15");
        }
        
        [TestMethod]
        public void Test_15_30_Receiverr_Win()
        {
            player2.setCurrentPoint("30");

            Assert.AreEqual(player2.getCurrentPoint(), "30");
        }
        
        [TestMethod]
        public void Test_15_30_Serverr_Losee()
        {
            player1.setCurrentPoint("15");

            Assert.AreEqual(player1.getCurrentPoint(), "15");
        }
        
        [TestMethod]
        public void Test_15_30_Receiver_Winn()
        {
            player2.setCurrentPoint("15");
            player2.increasePoints();

            Assert.AreEqual(player2.getCurrentPoint(), "30");
        }
        
        
        [TestMethod]
        public void Test_0_40_Server_Win()
        {
            player1.setCurrentPoint("30");
            player1.increasePoints();

            Assert.AreEqual(player1.getCurrentPoint(), "40");
        }
        
        [TestMethod]
        public void Test_0_40_Receiver_Lose()
        {
            player2.setCurrentPoint("0");

            Assert.AreEqual(player2.getCurrentPoint(), "0");
        }
        
        [TestMethod]
        public void Test_15_40_Server_Lose()
        {
            player1.setCurrentPoint("15");

            Assert.AreEqual(player1.getCurrentPoint(), "15");
        }
        
        [TestMethod]
        public void Test_15_40_Receiver_Win()
        {
            player2.setCurrentPoint("30");
            player2.increasePoints();

            Assert.AreEqual(player2.getCurrentPoint(), "40");
        }
        
        [TestMethod]
        public void Test_40_15_Server_Win()
        {
            player1.setCurrentPoint("30");
            player1.increasePoints();

            Assert.AreEqual(player1.getCurrentPoint(), "40");
        }
        
        [TestMethod]
        public void Test_40_15_Receiver_Lose()
        {
            player2.setCurrentPoint("15");

            Assert.AreEqual(player2.getCurrentPoint(), "15");
        }
        
        [TestMethod]
        public void Test_30_30_Server_equal_Receiver()
        {
            player1.setCurrentPoint("30");

            Assert.AreEqual(player1.getCurrentPoint(), "30");
        }
        
        [TestMethod]
        public void Test_30_30_Server_equall_Receiver()
        {
            player2.setCurrentPoint("15");
            player2.increasePoints();

            Assert.AreEqual(player2.getCurrentPoint(), "30");
        }
        
        [TestMethod]
        public void Test_15_40_Serverr_Lose()
        {
            player1.setCurrentPoint("0");
            player1.increasePoints();

            Assert.AreEqual(player1.getCurrentPoint(), "15");
        }
        [TestMethod]
        public void Test_15_40_Receiverr_Win()
        {
            player2.setCurrentPoint("40");

            Assert.AreEqual(player2.getCurrentPoint(), "40");
        }
        
       
        [TestMethod]
        public void Test_40_15_Serverr_Win()
        {
            player1.setCurrentPoint("30");
            player1.increasePoints();

            Assert.AreEqual(player1.getCurrentPoint(), "40");
        }
        
        [TestMethod]
        public void Test_40_15_Receiverr_Lose()
        {
            player2.setCurrentPoint("15");

            Assert.AreEqual(player2.getCurrentPoint(), "15");
        }
        
        
        [TestMethod]
        public void Test_40_30_Server_Win()
        {
            player1.setCurrentPoint("30");
            player1.increasePoints();

            Assert.AreEqual(player1.getCurrentPoint(), "40");
        }
        [TestMethod]
        public void Test_40_30_Receiver_Lose()
        {
            player2.setCurrentPoint("30");

            Assert.AreEqual(player2.getCurrentPoint(), "30");
        }
        
        [TestMethod]
        public void Test_30_40_Server_Lose()
        {
            player1.setCurrentPoint("30");

            Assert.AreEqual(player1.getCurrentPoint(), "30");
        }
        [TestMethod]
        public void Test_30_40_Receiver_Win()
        {
            player2.setCurrentPoint("30");
            player2.increasePoints();

            Assert.AreEqual(player2.getCurrentPoint(), "40");
        }
        
        
        [TestMethod]
        public void Test_2_5_Server_Deuce()
        {
            player1.setCurrentPoint("40");

            Assert.AreEqual(player1.getCurrentPoint(), "40");
        }

        [TestMethod]
        public void Test_2_5_Receiver_Deuce()
        {
            player2.setCurrentPoint("30");
            player2.increasePoints();

            Assert.AreEqual(player2.getCurrentPoint(), "40");
        }
    }
}
